package com.dmwork.service.message.controller.front.me.feign;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.dmwork.common.base.result.R;
import com.dmwork.common.base.util.JwtInfo;
import com.dmwork.common.base.util.JwtUtils;
import com.dmwork.service.message.entity.CommentLikeMessage;
import com.dmwork.service.message.service.CommentLikeMessageService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

/**
 * <p>
 * 点赞消息表 前端控制器
 * </p>
 *
 * @author 李天
 * @since 2021-05-14
 */
@RestController
@RequestMapping("/front/dm_work/message/comment_like_message/me/feign")
public class FrontMeFeignCommentLikeMessageController {

    @Autowired
    private CommentLikeMessageService commentLikeMessageService;

    @ApiOperation("获取点赞消息的id列表")
    @GetMapping("get_comment_like_message_list/{page}/{limit}")
    public R getCommentLikeMessageList(HttpServletRequest request, @PathVariable Integer page, @PathVariable Integer limit) {
        JwtInfo jwtInfo = JwtUtils.getCustomerInfoByJwtToken(request);
        Page<CommentLikeMessage> messagePage = new Page<>(page, limit);
        QueryWrapper<CommentLikeMessage> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("customer_id", jwtInfo.getId()).orderByDesc("gmt_create");
        messagePage = commentLikeMessageService.page(messagePage, queryWrapper);
        return R.ok().data("total", messagePage.getTotal()).data("rows", messagePage.getRecords());
    }

}

